#ifndef FILETHREAD_H
#define FILETHREAD_H

#include <QThread>
#include <QMap>
#include <QTcpServer>
#include <QTcpSocket>
#include <QJsonDocument>
#include <QDebug>
#include <QCoreApplication>
#include <QDir>
#include <QThread>
#include <QPointer>
#include "constant.h"
#include "chatmessage/Headers/myfileinfo.h"

class FileThread :public QThread
{
public:
    FileThread();
private:
    QString server_downloadPath;
    bool is_feil;
    void FileTcp();
    qint64 FileTcpPort;
    QTcpServer* FileTcpServer;
    QMap<QString,QTcpSocket*>FileTcpList;
    /*File*/
    QString ServerFilePath;
    bool is_images;
    QString toServerFileSize;
    qint64 m_fileInfoWriteBytes;
    qint64 typeMsgSize;
    QString m_sendFilePath;
    QMap<QString,MyFileInfo*>ServerFileInfo;
    QMap<QString,QString>getServerFileSize;
    QMap<QString,QString>filePath;
    QMap<QTcpSocket*,QTcpSocket*>fileSendUser;
    QMap<QTcpSocket*,QTcpSocket*>fileToUser;
    QMap<QTcpSocket*,QString>fileSendUserList;
    QMap<QTcpSocket*,bool>is_dow;
    QMap<QTcpSocket*,QString>UserList;
    QMap<QTcpSocket*,QString>clientData;
    QMap<QTcpSocket*,QString> m_localFile;
    QMap<QTcpSocket*,qint64> m_sendFileSize;
protected:
    void ToServerFileInfo(QTcpSocket *socket);
    void ToServerFileData(QTcpSocket *socket);
    QPair<QString,qint64> getFileContent(QString filePath);
    void fileInfoRead(QMap<QString, QVariant> map);
    void fileDataRead(QTcpSocket* socket);
    void run() override;
};

#endif // FILETHREAD_H
